﻿<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="zh_CN">
<head>
<%@ include file="../common/header.jsp"%>
</head>
<body>

	<div class="container " style="margin-top: 20px">
		<%@ include file="../common/top.jsp"%>

		<div class="row">
			<div class="col-sm-3">
				<c:set var="menu" value="systemDictionary" />
				<%@ include file="../common/menu.jsp"%>
			</div>
			<div class="col-sm-9">
				<div class="row">
					<div class="col-sm-12">
						<h1 class="page-head-line">字典目录管理</h1>
					</div>
				</div>
				<form class="form-inline" id="searchForm" action="/systemDictionary/list.do"
					method="post">
					<input type="hidden" name="currentPage" id="currentPage" value="1">
					<div class="form-group">
						<label>关键字:</label> <input type="text" class="form-control"
							name="keyword" value="" placeholder="请输入标题">
					</div>

					<button type="submit" class="btn btn-primary">
						<span class="glyphicon glyphicon-search"></span> 查询
					</button>
					<button type="button" class="btn btn-success inputBtn">
						<span class="glyphicon glyphicon-plus"></span> 添加
					</button>
				</form>

				<table class="table table-striped table-hover">
					<tr>
						<th>编号</th>
						<th>字典标题</th>
						<th>字典编码</th>
						<th>字典介绍</th>
						<th>操作</th>
					</tr>

					<c:forEach var="entity" items="${pageInfo.list}">
						<tr>
							<td>${entity.id}</td>
							<td>${entity.title}</td>
							<td>${entity.sn }</td>
							<td>${entity.intro}</td>
							<td>
							<a class="btn btn-info btn-xs inputBtn" data-json='${entity.json}'> <span
									class="glyphicon glyphicon-pencil"></span> 编辑</a>
							<a href="/systemDictionary/delete.do?id=${entity.id}" class="btn btn-danger btn-xs"> 
								<span class="glyphicon glyphicon glyphicon-trash"></span> 删除</a>		
							</td>
						</tr>
					</c:forEach>

				</table>

				<%@ include file="../common/page.jsp"%>
			</div>
		</div>
	</div>
	
	<div class="modal fade" id="inputModal" tabindex="-1" role="dialog"
		aria-labelledby="inputModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="myModalLabel">编辑</h4>
				</div>
				<div class="modal-body">
					<!--填充编辑界面-->
	                <form class="form-horizontal" action="/systemDictionary/saveOrUpdate.do" method="post" id="editForm">
	                    <input type="hidden" name="id"/>
	                    <div class="form-group" >
	                        <label class="col-lg-4 control-label">字典标题：</label>
	                        <div class="col-lg-6">
	                            <input type="text" class="form-control" name="title" placeholder="请输入字典标题"/>
	                        </div>
	                    </div>
	                    <div class="form-group">
	                        <label class="col-lg-4 control-label">字典编码：</label>
	                        <div class="col-lg-6">
	                            <input type="text" class="form-control" name="sn" placeholder="请输入字典编码"/>
	                        </div>
	                    </div>
	                    <div class="form-group">
	                        <label class="col-lg-4 control-label">字典简介：</label>
	                        <div class="col-lg-6">
	                            <input type="text" class="form-control" name="intro" placeholder="请输入字典简介"/>
	                        </div>
	                    </div>
	                </form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭
					</button>
					<button type="button" class="btn btn-primary submitBtn">
						保存</button>
				</div>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal -->

<script>
	$(function() {
		//添加和编辑按钮点击事件
		$(".inputBtn").click(function() {
			//清空模态框数据
			$("#editForm input").val("");
			//加填数据data-json
			var json = $(this).data("json");
			if (json) {
				$("#editForm input[name='id']").val(json.id);
				$("#editForm input[name='sn']").val(json.sn);
				$("#editForm input[name='title']").val(json.title);
				$("#editForm input[name='intro']").val(json.intro);
			}
			//弹出编辑模态框
			$("#inputModal").modal("show");
			
		});
		
		
		//点击提交 
		$(".submitBtn").click(function() {
			$("#editForm").submit();
		});
	});
</script>
</body>
</html>